<?php
class Update extends PageBaseUpdate {
    public function InitializeComponent(){
		$this->ClassName = "Menu";
		$this->AddKeyField("id", "Idmenu");
		$this->AddControlToField("txtTexto", "Texto");
		$this->AddControlToField("ddlPadre", "Idpadre");
		$this->AddControlToField("txtOrden", "Orden");
		$this->AddControlToField("ddlPagina", "Idpagina");
		$this->AddControlToField("txtHtmlId", "Htmlidattribute");
		$this->AddControlToField("chkActivo", "Enabled");
		$this->AddControlToField("chkVisible", "Visible");
		$this->Back("SetBackPage");
	}

	protected function LoadDataRelated(){
		$c = new Criteria();
		$c->addAscendingOrderByColumn(MenuPeer::TEXTO);
		$c->add(MenuPeer::IDPADRE,1);

        $id = $this->Request["id"];
        //si es un update, filtro ese registro en la ddl de sectores superiores
        if(!is_null($id)){
            $c->add(MenuPeer::IDMENU,$id,Criteria::NOT_EQUAL);
        }

        $this->LoadDdl(
			"Menu",
			"ddlPadre",
			"Idmenu",
			"Texto",
			"1",
			"Seleccione",
			"1",
			$c
		);

		$c = new Criteria();
		$c->addAscendingOrderByColumn(PaginaPeer::NOMBRE);

        $this->LoadDdl(
			"Pagina",
			"ddlPagina",
			"Idpagina",
			"Nombre",
			"DBNull",
			"Seleccione",
			"DBNull",
			$c
		);
    }

	protected function btnAceptar_OnClick(){
		if($this->IsValid){
        	$this->Save(BackType::GoBackPage);
		}
	}

    public function btnCancelar_OnClick($sender, $param){
        $this->Back("GoBackPage");
    }

}
?>